package com.fit.dao.payment;

import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import com.fit.dao.registration.LicencePlateDAO;
import com.fit.entities.Payment;
import com.fit.entities.LicencePlate;
import com.fit.entities.Registration;
import com.fit.entities.Vehicle;

public class PaymentDAOImpl implements PaymentDAO {

	@Inject
	private Session session;
	
	@Inject
	private LicencePlateDAO registrationDAO;

	public boolean save(Payment payment) {
		if (payment != null) {
			session.save(payment);
			return true;
		}
		return false;
	}

	public Payment findById(Long id) {
		return (Payment) session.get(Payment.class, id);
	}

	public List<Payment> findByRegistration(Registration registration) {
		List<Payment> list = session.createCriteria(Payment.class).add(Restrictions.eq("registration", registration)).list();
		return list;
	}

}
